package dp.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyHander implements InvocationHandler {

	public Object subject;
	
	public ProxyHander(Object subject) {
		this.subject = subject;
	}
	
	public Object bind() {
		return Proxy.newProxyInstance(subject.getClass().getClassLoader(), subject.getClass().getInterfaces(), this);
	}
	
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		
		System.out.println(" before do some thing method");
		
		Object rtnObject = method.invoke(subject, args);
		
		System.out.println(" after do some thing method");
		
		return rtnObject;
	}

}
